package data;
import java.awt.event.KeyEvent;
import java.io.File;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import data.HighscoreEntry.DIFFICULTY;

/**
 * 
 * Contains all editable settings and a complete array of playable challenges. The class is optimized for XML output.
 *
 */
@XmlRootElement(namespace = "http://se.reaktionsspiel.options.de/", name = "Reaktionsspiel_Options")
public class Options {
	@XmlElement(name = "challenge")
	
	private ChallengeData[] challenges;
	
	private Player[] availiblePlayers;
	/** An enumeration of all playable chellenges */
	public static enum challengesEnum{ElementCount, FallingBox, FindTheCharacter, FindTheOriginal /*, Quiz */};  // Aufruf: challengesEnum.X.ordinal()
	DIFFICULTY difficulty;

	private static File optionsFile = new File("res\\optionsTest.xml");




	public Options(){
		challenges = new ChallengeData[challengesEnum.values().length];
		

		challenges[challengesEnum.ElementCount.ordinal()] = new ChallengeData("Element Count", "Press when the number of the shown elements matches the number in the top left corner!",3);
		challenges[challengesEnum.FallingBox.ordinal()] = new ChallengeData("Falling Box", "Press when the element is completely hidden by the the bar!", 3);
		challenges[challengesEnum.FindTheCharacter.ordinal()] = new ChallengeData("Find The Character", "Press when you see the Character!", 3);
		challenges[challengesEnum.FindTheOriginal.ordinal()] = new ChallengeData("Find The Same", "Press when the shapes are equal!", 3);
//		challenges[challengesEnum.Quiz.ordinal()] = new ChallengeData("Quiz");
		

		Player pl1 = new Player("Spieler 1", 0, KeyEvent.VK_A, true);
		Player pl2 = new Player("Spieler 2", 0, KeyEvent.VK_SPACE, true);
		Player pl3 = new Player("Spieler 3", 0, KeyEvent.VK_O, true);
		Player pl4 = new Player("Spieler 4", 0, KeyEvent.VK_ENTER, true);

		availiblePlayers = new Player[] {pl1, pl2, pl3, pl4};
		
		
		difficulty = DIFFICULTY.EASY;

	}
	
	public DIFFICULTY getDifficulty() {
		return difficulty;
	}
	
	public void setDifficulty(DIFFICULTY i) {
		difficulty = i;
	}
	
		
	/**
	 * Sets the file where the XML representation of Options objects should be stored. Caution: The file will be the same for all instances which may cause overwriting and data loss issues. 
	 * @param optFile file for the storage of user settings.
	 */
	public static void setOptionsFile(File optFile) {
		Options.optionsFile = optFile;
	}
	
	/**
	 * Obtains the file where the XML representation of Options objects should be stored. Caution: The file will be the same for all instances which may cause overwriting and data loss issues. 
	 * @return file
	 */
	public static File getOptionsFile() {
		return Options.optionsFile;
	}

	/**
	 * Obtains an array filled with ChallengeData classes for every single loaded challenge.
	 * @return array with ChallengeData instances containing information about challenges.
	 */
	public ChallengeData[] getChallenges() {
		return challenges;
	}

	public Player[] getPlayers() {
		return availiblePlayers;
	}

	public void setPlayers(Player[] availiblePlayers) {
		this.availiblePlayers = availiblePlayers;
	}
}
